﻿<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
	<meta charset="utf-8" />
    <script src="../js/jquery-1.8.3.min.js"></script>
    <script type="text/javascript">
        $(function () {
            //测试调用LoggeryHandler.ashx
            $("#InitPool").click(function () {
                $.get("GetHandler.ashx", { "action": "InitPool" }, function (data) {
                    //alert(data.Data);
                    console.log(data.Data);
                })
            })
            $("#DrawPrize").click(function () {
                $.post("Posthandler.ashx", { "action": "CheckBcUser", "openId": "oiz3Mvrq3Z4AVAyBSHusrpVRZtcM" },
                    function (data) {
                    console.log(data.Data);
                })
            })

            $("#Add").click(function () {
                $.post("Posthandler.ashx", { "action": "Add", "CardID": "KM0000027427", "CardCode": "1110018261", "ShopID": "KM000049" },
                    function (data) {
                        console.log(data.Data);
                    })
            })

            $("#List").click(function () {
                $.post("Posthandler.ashx", { "action": "LotteryList", "openId": "oiz3Mvrq3Z4AVAyBSHusrpVRZtcM" },
                    function (data) {
                        $("#msg").empty();
                        var r = "";
                        var d = data.Data;
                        $.each(d,function (i) {
                            r += "奖品:<span>" + d[i].ProductType + "</span>   时间:<span>" + d[i].CreateDate + "</span></br>"
                        });
                    
                        $("#msg").append(r);
                    })
            })
            $("#startFuc").click(function () {   
                var i = setInterval(StartFun, 1000); //86400000:24小时  108000000:30小时    
               
            })
            function StartFun() {
                var d = new Date();
                var hour = d.getHours();
                var m = d.getMinutes();
                var s = d.getSeconds();
                if (hour == 2 && m == 0 && s == 0) {
                    $.get("GetHandler.ashx", { "action": "InitPool" }, function (data) {
                        //alert(data.Data);
                        console.log(data.Data);
                    })
                }
                //console.log("I:");
            }

            $("#lotteryIntegral").click(function() {
                $("#msg").text("");
                for (var i = 0; i < 50; i++) {
                    $.post("ActivityHandler.ashx",
                        { "action": "SummaryList", "type": 1 },
                        function(data) {
                            $("#msg").text(data);
                            //if (data.Data.indexOf("10元优惠券") >= 0)
                            //    $("#msg").append("奖品:<span style='color:green'>" + data.Data + "</span></br>");
                            //else if (data.Data.indexOf("斜挎包") >= 0)
                            //    $("#msg").append("奖品:<span style='color:blue'>" + data.Data + "</span></br>");
                            //else if (data.Data.indexOf("IPad") >= 0)
                            //    $("#msg").append("奖品:<span style='color:red'>" + data.Data + "</span></br>");
                            //else if (data.Data.indexOf("iPhoneX") >= 0)
                            //    $("#msg").append("奖品:<span style='color:red'>" + data.Data + "</span></br>");
                            //else if (data.Data.indexOf("未中奖") >= 0)
                            //    $("#msg").append("奖品:<span style='color:gray'>" + data.Data + "</span></br>");
                        });
                }

            });

            $("#week520").click(function() {
                $("#msg").text("");
                $.post("BaseHandler.ashx",
                    { "action": "InitUser", "type": 1,"code":"" },
                    function (data) {
                        if (data.Success) {
                            $.post("ActivityHandler.ashx",
                                { "action": "Lottery520", "openId": "" },
                                function (data) {
                                    $("#msg").text(data.Data);
                                });
                        }
                        $("#msg").text(stringify.json(data.Data));
                        
                    });
            });

        })

      
    </script>
</head>
<body>
    <button  id="InitPool">初始化奖池</button>

    <button id="DrawPrize">抽奖</button>

    <button id="Add">添加积分</button>

    <button id="List">中奖列表</button>

<button id="startFuc">启动->初始化奖池</button>

<button id="lotteryIntegral">AliasMethod算法测试</button>
    
<button id="week520">520会员狂欢周</button>


<div id="msg"></div>
</body>
</html>
